\chapter{Singular homology}
\label{ch:singular_homology}
Now that we've defined $\pi_1(X)$,
we turn our attention to a second way of capturing the same idea, $H_1(X)$.
We'll then define $H_n(X)$ for $n \ge 2$.
The good thing about the $H_n$ groups is that, unlike the $\pi_n$ groups,
they are much easier to compute in practice.
The downside is that their definition will require quite a bit of setup,
and the ``algebraic'' part of ``algebraic topology'' will become a lot more technical.

\section{Simplices and boundaries}
\prototype{$\partial[v_0, v_1, v_2] = [v_0,v_1]-[v_0,v_2]+[v_1,v_2]$.}
First things first:
\begin{definition}
	The \vocab{standard $n$-simplex}, denoted $\Delta^n$, is defined as
	\[ \left\{ (x_0 , x_1, \dots x_n) \mid x_i \ge 0, x_0+\dots+x_n=1 \right\}. \]
	Hence it's the convex hull of some vertices $[v_0, \dots, v_n]$.
	Note that we keep track of the order $v_0$, \dots, $v_n$ of the vertices,
	for reasons that will soon become clear.

	Given a topological space $X$, a \vocab{singular $n$-simplex} is a map $\sigma \colon \Delta^n \to X$.
\end{definition}
\begin{example}
	[Singular simplices]
	\listhack
	\label{ex:simplex}
	\begin{enumerate}[(a)]
		\ii Since $\Delta^0 = [v_0]$ is just a point,
		a singular $0$-simplex $X$ is just a point of $X$.
		\ii Since $\Delta^1 = [v_0, v_1]$ is an interval,
		a singular $1$-simplex $X$ is just a path in $X$.
		\ii Since $\Delta^2 = [v_0, v_1, v_2]$ is an equilateral triangle,
		a singular $2$-simplex $X$ looks a ``disk'' in $X$.
	\end{enumerate}
	Here is a picture of all three in a space $X$:
	\begin{center}
		\begin{asy}
			size(8cm);
			bigblob("$X$");
			dot("$\sigma^0$", (-3.7,2.5), dir(-90));

			pen hg = heavygreen;
			pair A0 = (-2.7, 1.1);
			pair A1 = (-2.9, -2.3);
			dot("$v_0$", A0, dir(90), hg);
			dot("$v_1$", A1, dir(-90), hg);
			path s1 = A0..(-3.1,0.7)..A1;
			draw(s1, hg, EndArrow);
			label("$\sigma^1$", s1, dir(10), hg);

			pen rr = red;
			pair B0 = (1, 1.8);
			pair B1 = (-0.7, -1.1);
			pair B2 = (1.9, -1.9);
			dot("$v_0$", B0, dir(90), rr);
			dot("$v_1$", B1, dir(210), rr);
			dot("$v_2$", B2, dir(330), rr);
			pair b0 = (0,0);
			pair b1 = (0,-2);
			pair b2 = (1.6,0.3);
			draw(B0..b0..B1, rr, EndArrow);
			draw(B1..b1..B2, rr, EndArrow);
			draw(B2..b2..B0, rr, EndArrow);
			fill(B0..b0..B1--B1..b1..B2--B2..b2..B0--cycle, lightred+opacity(0.2));
			label("$\sigma^2$", (B0+B1+B2)/3, rr);
		\end{asy}
	\end{center}
	The arrows aren't strictly necessary, but I've included them
	to help keep track of the ``order'' of the vertices;
	this will be useful in just a moment.
\end{example}

Now we're going to do something much like
when we were talking about Stokes' theorem:
we'll put a boundary $\partial$ operator on the singular $n$-simplices.
This will give us a formal linear sums of $n$-simplices $\sum_k a_k \sigma_k$,
which we call an \vocab{$n$-chain}.

In that case,
\begin{definition}
	Given a singular $n$-simplex $\sigma$ with vertices $[v_0, \dots, v_n]$,
	note that for every $i$ we have an $(n-1)$ simplex $[v_0, \dots, v_{i-1}, v_{i+1}, \dots, v_n]$.
	The \vocab{boundary operator} $\partial$ is then defined by
	\[ \partial(\sigma) \defeq \sum_i (-1)^i
		\left[ v_0, \dots, v_{i-1}, v_{i+1}, \dots, v_n \right]. \]
	The boundary operator then extends linearly to $n$-chains:
	\[ \partial\left( \sum_k a_k \sigma_k \right) \defeq \sum a_k \partial(\sigma_k). \]
	By convention, a $0$-chain has empty boundary.
\end{definition}
\begin{example}
	[Boundary operator]
	Consider the chains depicted in \Cref{ex:simplex}. Then
	\begin{enumerate}[(a)]
		\ii $\partial\sigma^0 = 0$.
		\ii $\partial(\sigma^1) = [v_1] - [v_0]$:
		it's the ``difference'' of the $0$-chain corresponding to point $v_1$
		and the $0$-chain corresponding to point $v_0$.
		\ii $\partial(\sigma^2) = [v_0,v_1] - [v_0,v_2] + [v_1, v_2]$;
		i.e.\ one can think of it as the sum of the three oriented arrows
		which make up the ``sides'' of $\sigma^2$.
		\ii Notice that if we take the boundary again, we get
		\begin{align*}
			\partial(\partial(\sigma^2))
			&= \partial([v_0,v_1]) - \partial([v_0,v_2]) + \partial([v_1,v_2]) \\
			&= \left( [v_1]-[v_0] \right) - \left( [v_2]-[v_0] \right) + \left( [v_2]-[v_1] \right)  \\
			&= 0.
		\end{align*}
	\end{enumerate}
\end{example}

The fact that $\partial^2 = 0$ is of course not a coincidence.
\begin{theorem}
	[$\partial^2=0$]
	For any chain $c$, $\partial(\partial(c)) = 0$.
\end{theorem}
\begin{proof}
	Essentially identical to \Cref{prob:partial_zero}:
	this is just a matter of writing down a bunch of $\sum$ signs.
	Diligent readers are welcome to try the computation.
\end{proof}
\begin{remark}
	The eerie similarity between the chains used to integrate differential forms
	and the chains in homology is not a coincidence.
	The de Rham cohomology, discussed much later, will make the relation explicit.
\end{remark}

\section{The singular homology groups}
\prototype{Probably $H_n(S^m)$, especially the case $m = n =1$.}
Let $X$ be a topological space, and let $C_n(X)$ be the free abelian group
of $n$-chains of $X$ that we defined earlier.
Our work above gives us a boundary operator $\partial$, so we have a sequence of maps
\[ \dots \taking\partial C_3(X) \taking\partial C_2(X)
	\taking\partial C_1(X) \taking\partial C_0(X) \taking\partial 0 \]
(here I'm using $0$ to for the trivial group, which is standard notation for abelian groups.)
We'll call this the \vocab{singular chain complex}.

Now, how does this let us detect holes in the space?
To see why, let's consider an annulus, with a $1$-chain $c$ drawn in red:
\begin{center}
	\begin{asy}
		size(6cm);
		pair O = origin;
		filldraw(CR(O, 6), lightblue+opacity(0.2), blue);
		filldraw(CR(O, 1), white, blue);
		label("$X$", 6*dir(45), dir(45));
		pen rr = red;
		pair v0 = 5*dir(100);
		pair v1 = 4*dir(220);
		pair v2 = 2.2*dir(330);
		dot("$v_0$", v0, dir(v0), rr);
		dot("$v_1$", v1, dir(v1), rr);
		dot("$v_2$", v2, dir(v2), rr);
		draw(v0..(3.2*dir(110))..v1, rr, EndArrow);
		draw(v1..(2.1*dir(270))..v2, rr, EndArrow);
		draw(v2..(3.6*dir(45))..v0, rr, EndArrow);
	\end{asy}
\end{center}
Notice that
\[ \partial c = ([v_1]-[v_0]) - ([v_2]-[v_0]) + ([v_2]-[v_1]) = 0 \]
and so we can say this $1$-chain $c$ is a ``cycle'',
because it has trivial boundary.
However, $c$ is not itself the boundary of any $2$-chain,
because of the hole in the center of the space
--- it's impossible to ``fill in'' the interior of $c$!
So, we have detected the hole by the algebraic fact that
\[ c \in \ker\left( C_1(X) \taking{\partial} C_0(X) \right)
	\qquad\text{but}\qquad
	c \notin \img \left( C_2(X) \taking{\partial} C_1(X) \right). \]
Indeed, if the hole was not present then this statement would be false.

\begin{remark}
	\label{remark:different_holes}
	Note that homotopy and homology captures slightly different notion of ``holes''.
	For example, let $T$ be a torus.
	Then, every map $S^2 \to T$ is nulhomotopic so $\pi_2(T)$ is trivial,
	but, as we will see in \Cref{prop:homology_torus}, $H_2(T) \cong \ZZ$.

	At least in the case of $n = 1$, then \Cref{thm:hurewicz} states that for any path-connected
	space $X$ and $x_0 \in X$, then $H_1(X)$ is the abelianization of $\pi_1(X, x_0)$,
	which is pretty much the best result you can expect --- $H_1(X)$ must be abelian, while
	$\pi_1(X, x_0)$ need not be abelian.
	Nevertheless, it is still possible that $\pi_1(X, x_0)$ is nontrivial and $H_1(X)$ is trivial
	--- see \url{https://math.stackexchange.com/q/1052414} for an example.
\end{remark}

We can capture this idea in any dimension, as follows.
\begin{definition}
	\label{def:cycle_and_boundary}
	Let
	\[ \dots \taking\partial C_2(X) \taking\partial C_1(X) \taking\partial C_0(X) \taking\partial 0 \]
	as above.
	We say that $c \in C_n(X)$ is:
	\begin{itemize}
		\ii a \vocab{cycle} if $c \in \ker\left( C_{n}(X) \taking\partial C_{n-1}(X) \right)$,
		and
		\ii a \vocab{boundary} if $c \in \img \left( C_{n+1}(X) \taking\partial C_n(X) \right)$.
	\end{itemize}
	Denote the cycles and boundaries by $Z_n(X), B_n(X) \subseteq C_n(X)$, respectively.%
	\footnote{We don't use $C_n(X)$ to denote cycles --- apart from the obvious reason that the
	notation is already used, the letter $Z$ comes from the German word ``Zyklus''.}
\end{definition}

\begin{ques}
	Just to get you used to the notation:
	check that $B_n$ and $Z_n$ are themselves abelian groups,
	and that $B_n(X) \subseteq Z_n(X) \subseteq C_n(X)$.
\end{ques}

The key point is that we can now define:
\begin{definition}
	The \vocab{$n$th homology group} $H_n(X)$ is
	defined as \[ H_n(X) \defeq Z_n(X) / B_n(X). \]
\end{definition}
\begin{example}
	[The zeroth homology group]
	Let's compute $H_0(X)$ for a topological space $X$.
	We take $C_0(X)$, which is just formal linear sums of points of $X$.

	First, we consider the kernel of $\partial \colon C_0(X) \to 0$,
	so the kernel of $\partial$ is the entire space $C_0(X)$:
	that is, every point is a ``cycle''.

	Now, what is the boundary?
	The main idea is that $[b] - [a] = 0$ if and only if
	there's a $1$-chain which connects $a$ to $b$, i.e.\
	there is a path from $a$ to $b$.
	In particular,
	\[ \text{$X$ path connected} \implies H_0(X) \cong \ZZ. \]
\end{example}
More generally, we have
\begin{proposition}[Homology groups split into path-connected components]
	If $X = \bigcup_\alpha X_\alpha$ is a decomposition into path-connected components,
	then we have \[ H_n(X) \cong \bigoplus_\alpha H_n(X_\alpha). \]
	In particular, if $X$ has $r$ path-connected components, then $H_0(X) \cong \ZZ^{\oplus r}$.
\end{proposition}
(If it's surprising to see $\ZZ^{\oplus r}$, remember that
an abelian group is the same thing as a $\ZZ$-module,
so the notation $G \oplus H$ is customary in place of $G \times H$
when $G$, $H$ are abelian.)

Now let's investigate the first homology group.
\begin{theorem}[Hurewicz theorem]
	\label{thm:hurewicz}
	Let $X$ be path-connected.
	Then $H_1(X)$ is the \emph{abelianization} of $\pi_1(X, x_0)$.
\end{theorem}
We won't prove this but you can see it roughly from the example.
The group $H_1(X)$ captures the same information
as $\pi_1(X, x_0)$: a cycle (in $Z_1(X)$) corresponds to the same thing
as the loops we studied in $\pi_1(X, x_0)$,
and the boundaries (in $B_1(X)$, i.e.\ the things we mod out by)
are exactly the nulhomotopic loops in $\pi_1(X, x_0)$.
The difference is that $H_1(X)$ allows loops to commute,
whereas $\pi_1(X, x_0)$ does not.

\begin{remark}[Digression: category theory interpretation]
	\label{remark:hurewicz}
	From this, you can say that there is a Hurewicz map $\pi_1(X, x_0) \taking\phi H_1(X)$
	for each $(X, x_0)$.

	But there is more than that: this map is \emph{natural}, in the sense that for $h \colon (X,
	x_0) \to (Y, y_0)$ map of pointed spaces, then
	\begin{center}
		\begin{tikzcd}
			\pi_1(X, x_0) \rar["h_\sharp"] \dar["\phi"] & \pi_1(Y, y_0) \dar["\phi"] \\
			H_1(X) \rar["h_\ast"] & H_1(Y) \\
		\end{tikzcd}
	\end{center}
	commutes.

	In category theory terms, we say that $\phi$ is a \emph{natural transformation}
	from $\pi_1$ to $H_1$.

	Another way to say this is: we have families of groups
	\[ \{ \pi_1(X, x_0) \mid (X, x_0)\text{ pointed space} \} \]
	and
	\[ \{ H_1(X) \mid (X, x_0)\text{ pointed space} \} \]
	then the natural transformation $\phi$ can be seen as a family of homomorphisms
	\[ \{ \phi \colon \pi_1(X, x_0) \to H_1(X) \mid (X, x_0)\text{ pointed space} \} \]
	satisfying the naturality conditions.

	Of course, the fact that $\pi_1$ is a functor means
	$\{ \pi_1(X, x_0) \mid (X, x_0)\text{ pointed space} \}$ is a lot more than a family of groups
	indexed by pointed spaces, as explained in \Cref{thm:fundgrp_functor}.
\end{remark}

\begin{example}
	[The first homology group of the annulus]
	To give a concrete example, consider the annulus $X$ above.
	We found a chain $c$ that wrapped once around the hole of $X$.
	The point is that in fact,
	\[ H_1(X) = \left< c\right> \cong \ZZ \]
	which is to say the chains $c$, $2c$, \dots\ are all not the same in $H_1(X)$,
	but that any other $1$-chain is equivalent to one of these.
	This captures the fact that $X$ is really just $S^1$.
\end{example}
\begin{example}
	[An explicit boundary in $S^1$]
	\label{ex:S1_c_minus_d}
	In $X = S^1$, let $a$ be the uppermost point and $b$ the lowermost point.
	Let $c$ be the simplex from $a$ to $b$ along the left half of the circle,
	and $d$ the simplex from $a$ to $b$ along the right half.
	Finally, let $\gamma$ be the simplex which represents a loop $\gamma$ from $a$
	to itself, wrapping once counterclockwise around $S^1$.
	We claim that in $H^1(S^1)$ we have
	\[ \gamma = c - d \]
	which geometrically means that $c-d$ represents wrapping once around
	the circle (which is of course what we expect).

	\begin{center}
		\begin{asy}
			size(5cm);
			real r = 0.8;
			pair a = dir(90);
			pair b = dir(-90);

			fill(unitcircle, lightblue+opacity(0.2));
			unfill(CR( -(1-r)/2*a, (1+r)/2 ));

			draw(arc(origin, a, -a), red);
			draw(arc((r-1)*a/2, -a, r*a), red, EndArrow);

			dot("$v_0=a$", r*a, dir(-90));
			dot("$v_1=a$", a, dir(90));
			dot("$v_2=b$", b, dir(-90));
			label("$\gamma$", dir(135), dir(135), red);
			draw(arc((r-1)*a/2, r*a, -a), blue, EndArrow);
			draw(arc(origin, 1, 90, -90), heavygreen, EndArrow);
			label("$c$", (1+r)/2*dir(180), dir(0), blue);
			label("$d$", dir(0), dir(0), heavygreen);
		\end{asy}
	\end{center}

	Indeed this can be seen from the picture above, where we have drawn
	a $2$-simplex whose boundary is exactly $\gamma - c + d$.
	The picture is somewhat metaphorical: in reality $v_0 = v_1 = a$,
	and the entire $2$-simplex is embedded in $S^1$.
	This is why singular homology is so-called: the images of the simplex
	can sometimes look quite ``singular''.
\end{example}

\begin{example}
	[The first homology group of the figure eight]
	Consider $X_8$ (see \Cref{ex:figure8}).
	Both homology and homotopy see the two loops in $X_8$, call them $a$ and $b$.
	The difference is that in $\pi_1(X_8, x_0)$,
	these two loops are not allowed to commute: we don't have $ab \neq ba$,
	because the group operation in $\pi_1$ is ``concatenate paths''.
	But in the homology group $H_1(X)$ the way we add $a$ and $b$
	is to add them formally, to get the $1$-chain $a+b$.
	So \[ H_1(X) \cong \ZZ^{\oplus 2} \quad\text{while}\quad \pi_1(X, x_0) = \left< a,b\right>. \]
\end{example}

\begin{example}
	[The homology groups of $S^2$]
	\label{ex:homology_group_sphere}
	Consider $S^2$, the two-dimensional sphere.
	Since it's path connected, we have $H_0(S^2) = \ZZ$.
	We also have $H_1(S^2) = 0$, for the same reason that $\pi_1(S^2)$ is trivial as well.
	On the other hand we claim that \[ H_2(S^2) \cong \ZZ. \]
	The elements of $H_2(S^2)$ correspond to wrapping $S^2$ in a tetrahedral bag
	(or two bags, or three bags, etc.).
	Thus, the second homology group lets us detect the spherical cavity of $S^2$.%
	\footnote{As remarked in \Cref{remark:different_holes}, unlike $\pi_2$,
		$H_2$ also detects other kinds of cavities, not just spherical.}
\end{example}
Actually, more generally it turns out that we will have
\[
	H_n(S^m) \cong
	\begin{cases}
		\ZZ & n=m \text{ or } n=0 \\
		0 & \text{otherwise}.
	\end{cases}
\]

\begin{example}
	[Contractible spaces]
	Given any contractible space $X$, it turns out that
	\[
		H_n(X)
		\cong
		\begin{cases}
			\ZZ & n = 0 \\
			0 & \text{otherwise}.
		\end{cases}
	\]
	The reason is that, like homotopy groups, it turns out
	that homology groups are homotopy invariant.
	(We'll prove this next section.)
	So the homology groups of contractible $X$ are the same
	as those of a one-point space, which are those above.
\end{example}

\begin{example}
	[Homology groups of the torus]
	While we won't be able to prove it for a while, it turns out that
	\[
		H_n(S^1 \times S^1)
		\cong
		\begin{cases}
			\ZZ & n = 0,2 \\
			\ZZ^{\oplus 2} & n = 1 \\
			0 & \text{otherwise}.
		\end{cases}
	\]
	The homology group at $1$ corresponds to our knowledge that $\pi_1(S^1 \times S^1) \cong \ZZ^2$
	and the homology group at $2$ detects the ``cavity'' of the torus.
\end{example}


This is fantastic and all, but how does one go about actually computing any homology groups?
This will be a rather long story, and we'll have to do a significant amount of both algebra and geometry
before we're really able to compute any homology groups.
In what follows, it will often be helpful to keep track of which things are purely algebraic
(work for any chain complex), and which parts are actually stating something which is geometrically true.

\section{The homology functor and chain complexes}
As I mentioned before, the homology groups are homotopy invariant.
This will be a similar song and dance as the work we did to
create a functor $\pi_1 \colon \catname{hTop}_\ast \to \catname{Grp}$.
Rather than working slowly and pulling away the curtain to reveal the category theory at the end,
we'll instead start with the category theory right from the start just to save some time.

\begin{definition}
	The category $\catname{hTop}$ is defined as follows:
	\begin{itemize}
		\ii Objects: topological spaces.
		\ii Morphisms: \emph{homotopy classes} of morphisms $X \to Y$.
	\end{itemize}
	In particular, $X$ and $Y$ are isomorphic in $\catname{hTop}$
	if and only if they are homotopic.
\end{definition}
You'll notice this is the same as $\catname{hTop}_\ast$,
except without the basepoints.

\begin{theorem}[Homology is a functor $\catname{hTop} \to \catname{Ab}$]
	\label{thm:Hn_functor}
	For any particular $n$, $H_n$ is a functor $\catname{hTop} \to \catname{Ab}$.
	In particular,
	\begin{itemize}
		\ii Given any map $f \colon X \to Y$, we get an induced map $f_\ast \colon H_n(X) \to H_n(Y)$.
		\ii For two homotopic maps $f, g \colon X \to Y$, $f_\ast = g_\ast$.
		\ii Two homotopic spaces $X$ and $Y$ have isomorphic homology groups:
		if $f \colon X \to Y$ is a homotopy then $f_\ast \colon H_n(X) \to H_n(Y)$ is an isomorphism.
		\ii (Insert your favorite result about functors here.)
	\end{itemize}
\end{theorem}

In order to do this, we have to describe how to take a map $f \colon X \to Y$
and obtain a map $H_n(f) \colon H_n(X) \to H_n(Y)$.
Then we have to show that this map doesn't depend on the choice of homotopy.
(This is the analog of the work we did with $f_\sharp$ before.)
It turns out that this time around, proving this is much more tricky,
and we will have to go back to the chain complex
$C_\bullet(X)$ that we built at the beginning.

\subsection{Algebra of chain complexes}
Let's start with the algebra.
First, I'll define the following abstraction of the complex to any sequence of abelian groups.
Actually, though, it works in any category (not just $\catname{AbGrp}$).
The strategy is as follows: we'll define everything that we need completely abstractly,
then show that the geometry concepts we want correspond to this setting.

\begin{definition}
	A \vocab{chain complex} is a sequence of groups $A_n$ and maps
	\[ \dots \taking{\partial} A_{n+1} \taking{\partial}
		A_n \taking{\partial} A_{n-1} \taking{\partial} \dots \]
	such that the composition of any two adjacent maps is the zero morphism.
	We usually denote this by $A_\bullet$.

	The $n$th homology group $H_n(A_\bullet)$ is defined
	as $\ker(A_n \to A_{n-1}) / \img(A_{n+1} \to A_n)$.
	Cycles and boundaries are defined in the same way as before.
\end{definition}
Obviously, this is just an algebraic generalization of the structure we previously looked at,
rid of all its original geometric context.

\begin{definition}
	A \vocab{morphism of chain complexes} (or chain map) $f \colon A_\bullet \to B_\bullet$ is
	a sequence of maps $f_n$ for every $n$ such that the diagram
	\begin{center}
	\begin{tikzcd}
		\dots \ar[r, "\partial_A"] & A_{n+1} \ar[r, "\partial_A"]  \ar[d, "f_{n+1}"] &
		A_n \ar[r, "\partial_A"] \ar[d, "f_n"] & A_{n-1} \ar[r, "\partial_A"] \ar[d, "f_{n-1}"] & \dots \\
		\dots \ar[r, "\partial_B"] & B_{n+1} \ar[r, "\partial_B"] &
		B_n \ar[r, "\partial_B"] & B_{n-1} \ar[r, "\partial_B"] & \dots
	\end{tikzcd}
	\end{center}
	commutes.
	Under this definition, the set of chain complexes becomes a category,
	which we denote $\catname{Cmplx}$.
\end{definition}

Note that given a morphism of chain complexes $f \colon A_\bullet \to B_\bullet$,
every cycle in $A_n$ gets sent to a cycle in $B_n$, since the square
\begin{center}
\begin{tikzcd}
	A_n \ar[r, "\partial_A"] \ar[d, "f_n"'] & A_{n-1} \ar[d, "f_{n-1}"] \\
	B_n \ar[r, "\partial_B"'] & B_{n-1}
\end{tikzcd}
\end{center}
commutes.
Similarly, every boundary in $A_n$ gets sent to a boundary in $B_n$. Thus,
\begin{moral}
	Every map of $f \colon A_\bullet \to B_\bullet$ gives a
	map $f_\ast \colon H_n(A) \to H_n(B)$ for every $n$.
\end{moral}
\begin{exercise}
	Interpret $H_n$ as a functor $\catname{Cmplx} \to \catname{Grp}$.
\end{exercise}

Next, we want to define what it means for two maps $f$ and $g$ to be homotopic.
Here's the answer:
\begin{definition}
	Let $f, g \colon A_\bullet \to B_\bullet$.
	Suppose that one can find a map $P_n \colon A_n \to B_{n+1}$ for every $n$ such that
	\[ g_n - f_n = \partial_B \circ P_n + P_{n-1} \circ \partial_A \]
	Then $P$ is a \vocab{chain homotopy} from $f$ to $g$
	and $f$ and $g$ are \vocab{chain homotopic}.
\end{definition}

We can draw a picture to illustrate this (warning: the diagonal dotted arrows do NOT commute
with all the other arrows):
\begin{center}
\begin{tikzcd}[sep=large]
	\dots \ar[r, "\partial_A"]
		& A_{n+1} \ar[r, "\partial_A"] \ar[d, "g-f"']
		& A_n \ar[r, "\partial_A"] \ar[d, "g-f"'] \ar[ld, dotted, "P_n"']
		& A_{n-1} \ar[r, "\partial_A"] \ar[d, "g-f"'] \ar[ld, dotted, "P_{n-1}"']
		& \dots \\
	\dots \ar[r, "\partial_B"]
		& B_{n+1} \ar[r, "\partial_B"]
		& B_n \ar[r, "\partial_B"]
		& B_{n-1} \ar[r, "\partial_B"]
		& \dots
\end{tikzcd}
\end{center}
The definition is that in each slanted ``parallelogram'', the $g-f$ arrow is the sum of the two
compositions along the sides.

\begin{remark}
	This equation should look terribly unmotivated right now,
	aside from the fact that we are about to show it does the right algebraic thing.
	Its derivation comes from the geometric context that we have deferred
	until the next section, where ``homotopy'' will naturally give ``chain homotopy''.
\end{remark}

Now, the point of this definition is that
\begin{proposition}[Chain homotopic maps induce the same map on homology groups]
	Let $f, g: A_\bullet \to B_\bullet$ be chain homotopic maps $A_\bullet \to B_\bullet$.
	Then the induced maps $f_\ast, g_\ast \colon H_n(A_\bullet) \to H_n(B_\bullet)$ coincide for each $n$.
\end{proposition}
\begin{proof}
	It's equivalent to show $g-f$ gives the zero map on homology groups,
	In other words, we need to check that every cycle of $A_n$ becomes
	a boundary of $B_n$ under $g-f$.
	\begin{ques}
		Verify that this is true. \qedhere
	\end{ques}
\end{proof}


\subsection{Geometry of chain complexes}
Now let's fill in the geometric details of the picture above.
First:
\begin{lemma}[Map of space $\implies$ map of singular chain complexes]
	Each $f \colon X \to Y$ induces a map $C_n(X) \to C_n(Y)$.
\end{lemma}
\begin{proof}
	Take the composition
	\[ \Delta^n \taking{\sigma} X \taking{f} Y. \]
	In other words, a path in $X$ becomes a path in $Y$, et cetera.
	(It's not hard to see that the squares involving $\partial$ commute;
	check it if you like.)
\end{proof}

Now, what we need is to show that if $f, g \colon X \to Y$ are homotopic,
then they are chain homotopic.
To produce a chain homotopy, we need to take every $n$-simplex $X$
to an $(n+1)$-chain in $Y$, thus defining the map $P_n$.

Let's think about how we might do this. Let's take the $n$-simplex $\sigma \colon \Delta^n \to X$
and feed it through $f$ and $g$; pictured below is a $1$-simplex $\sigma$ (i.e.\ a path in $X$)
which has been mapped into the space $Y$.
Homotopy means the existence of a map $F \colon X \times [0,1] \to Y$
such that $F(-,0) = f$ and $F(-,1) = g$, parts of which I've illustrated below with grey arrows
in the image for $Y$.

\begin{center}
	\begin{asy}
		size(14cm);
		bigblob("$Y$");
		pair A = (-3.5,2);
		pair B = (-2.2,-2);
		pair C = (2.2,1.6);
		pair D = (2.0, -1.1);

		pen rr = red;
		dot("$v_0$", A, dir(90), rr); dot("$v_1$", B, dir(-090), rr);
		path v = A..(-2,0)..B;
		draw(v, rr, EndArrow);
		label("$f(\sigma)$", v, dir(180), rr);

		pen hg = heavygreen;
		dot("$w_0$", C, dir(90), hg); dot("$w_1$", D, dir(-90), hg);
		path w = C..(2.3,0)..D;
		draw(w, hg, EndArrow);
		label("$g(\sigma)$", w, dir(0), hg);

		pen gr = grey + dashed;
		draw(A--C, gr, Margins);
		path F = A--D;
		draw(F, gr, Margins);
		label("$F$", F, dir(90), gr);
		draw(B--D, gr, Margins);

		add(shift(12.5,0)*CC());
		pair W = 1.5*dir(135);
		pair X = 1.5*dir(225);
		pair Y = 1.5*dir(45);
		pair Z = 1.5*dir(-45);
		dot("$v_0$", W, dir(W), rr);
		dot("$v_1$", X, dir(X), rr);
		dot("$w_0$", Y, dir(Y), hg);
		dot("$w_1$", Z, dir(Z), hg);

		label("$\Delta^1 \times [0,1]$", 2*dir(90), dir(90));
		pair A1 = (1.5,0);
		pair A2 = (3.5,0);
		pair A3 = (6.25,0);
		pair A4 = (7.5,0);
		draw(A1--A2, EndArrow);
		draw(A3--A4, EndArrow);
		label("$\boxed{X \times [0,1]}$", midpoint(A2--A3), blue);
		label("$F$", A3--A4, dir(90));
		label("$\sigma \times \operatorname{id}$", A1--A2, dir(90));

		draw(W--X, rr, EndArrow);
		draw(Y--Z, hg, EndArrow);
		draw(W--Y, gr);
		draw(X--Z, gr);
		draw(W--Z, gr);
	\end{asy}
\end{center}

This picture suggests how we might proceed:
we want to create a $2$-chain on $Y$ given the $1$-chains we've drawn.
The homotopy $F$ provides us with a ``square'' structure on $Y$,
i.e.\ the square bounded by $v_0$, $v_1$, $w_1$, $w_0$.
We split this up into two triangles; and that's our $2$-chain.

We can make this formal by taking $\Delta^1 \times [0,1]$ (which \emph{is} a square)
and splitting it into two triangles.
Then, if we apply $\sigma \times \id$, we'll get an $2$-chain in $X \times [0,1]$,
and then finally applying $F$ will map everything into our space $Y$.
In our example, the final image is the $2$-chain, consisting of two triangles,
which in our picture can be written as $[v_0, w_0, w_1] - [v_0, v_1, w_1]$;
the boundaries are given by the red, green, grey.

More generally, for an $n$-simplex $\phi = [x_0, \dots, x_n]$
we define the so-called \emph{prism operator} $P_n$
as follows. Set $v_i = f(x_i)$ and $w_i = g(x_i)$ for each $i$.
Then, we let
\[ P_n(\phi) \defeq \sum_{i=0}^n (-1)^i (F \circ (\phi\times\id))
	\left[ v_0, \dots, v_i, w_i, \dots, w_n \right]. \]
This is just the generalization of the construction above to dimensions $n > 1$;
we split $\Delta^n \times [0,1]$ into $n+1$ simplices,
map it into $X$ by $\phi \times \id$ and then push the whole thing into $Y$.
The $(-1)^i$ makes sure that the ``diagonal'' faces all cancel off with each other.

We now claim that for every $\sigma$,
\[ \partial_Y(P_n(\sigma)) = g(\sigma) - f(\sigma) - P_{n-1}(\partial_X\sigma). \]
In the picture, $\partial_Y \circ P_n$ is the boundary of the entire prism
(in the figure, this becomes the red, green, and grey lines, not including diagonal grey,
which is cancelled out).
The $g-f$ is the green minus the red,
and the $P_{n-1} \circ \partial_X$ represents the grey edges of the prism
(not including the diagonal line from $v_1$ to $w_0$).
Indeed, one can check (just by writing down several $\sum$ signs)
that the above identity holds.

As a picture:
\begin{center}
\begin{asy}
	size(10cm);

	pen rr = red;
	pen hg = heavygreen;
	pen gr = grey + dashed;

	label("$\underbrace{g(\sigma) - f(\sigma)} = \underbrace{\partial_Y(P_n(\sigma))} +
		\underbrace{P_{n-1}(\partial_X(\sigma))}$", (4, 9));

	draw((1.7, 8.6)--(1.5, 8.2), Arrow);
	draw((3.95, 8.6)--(4, 8.2), Arrow);
	draw((6.2, 8.6)--(7, 8.2), Arrow);

	draw((0, 8){dir(-70)}..(0, 6), rr, L="$f(\sigma)$");
	draw((2, 8){dir(-70)}..(2, 6), hg, L="$g(\sigma)$");
	label("$=$", (2.5, 7));

	draw((3, 8){dir(-70)}..(3, 6), rr);
	draw((5, 8){dir(-70)}..(5, 6), hg);
	draw((3, 8)--(5, 8), gr);
	draw((3, 6)--(5, 6), gr);
	label("$+$", (5.5, 7));

	draw((6, 8)--(8, 8), gr);
	draw((6, 6)--(8, 6), gr);

	fill((3, 5){dir(-70)}..(3, 3)--(5, 3){dir(70)}..(5, 5)--cycle, lightblue+opacity(0.2));
	draw((3, 5){dir(-70)}..(3, 3), rr);
	draw((5, 5){dir(-70)}..(5, 3), hg);
	draw((3, 5)--(5, 5), gr);
	draw((3, 3)--(5, 3), gr);
	draw((4, 5.1)--(4, 5.9), Arrow, L="$\partial_Y$");

	dot((7, 3), gr);
	dot((7, 5), gr);
	draw((7, 5.1)--(7, 5.9), Arrow, L="$P_0$");

	draw((5.5, 0){dir(70)}..(5.5, 2), L=Label("$\sigma$", Relative(0.8)));
	draw((5.4, 2.1)--(4.2, 2.9), Arrow, L="$P_1$");
	draw((5.6, 2.1)--(6.8, 2.9), Arrow, L="$\partial_X$");
\end{asy}
\end{center}

So that gives the chain homotopy from $f$ to $g$, completing the proof of \Cref{thm:Hn_functor}.

\section{More examples of chain complexes}
We now end this chapter by providing some more examples of chain complexes,
which we'll use in the next chapter to finally compute topological homology groups.

\begin{example}
	[Reduced homology groups]
	Suppose $X$ is a (nonempty) topological space.
	One can augment the standard singular complex as follows:
	do the same thing as before, but augment the end by adding a $\ZZ$,
	as shown:
	\[ \dots \to C_1(X) \to C_0(X) \taking{\eps} \ZZ \to 0 \]
	Here $\eps$ is defined by $\eps(\sum n_ip_i) = \sum n_i$ for points $p_i \in X$.
	(Recall that a $0$-chain is just a formal sum of points!)
	We denote this \vocab{augmented singular chain complex} by $\wt C_\bullet(X)$.

	This may seem like a random thing to do, but it can be justified
	by taking the definitions we started with and ``generalizing
	backwards''. Recall that an $n$-simplex is given by $n+1$
	vertices: $[v_0,\ldots,v_n]$. That suggests that a
	$(-1)$-simplex is given by $0$ vertices: $[]$!

	We reach the same conclusion if we apply the definition of the
	standard $n$-simplex using $n=-1$. $\Delta^{-1}$ must be the
	subset of $\RR^0$ consisting of all points whose coordinates are
	nonnegative and sum to $1$. There are no such points, so
	$\Delta^{-1} = \{\}$. Consequently, given a topological space
	$X$, a singular $(-1)$-simplex in $X$ must be a function
	$\{\} \to X$. There is one such function: the \emph{empty
		function}, whose image is the empty set.

	That is, every topological space $X$ has exactly one
	$(-1)$-simplex, which we identify with $\{\}$. Thus, the
	$(-1)$st chain group $C_{-1}(X)$ is the free abelian group
	generated by one element; ie, $\wt C_{-1}(X) \cong \mathbb{Z}$
	(where the isomorphism identifies $\{\}$ with $1$).

	What about boundaries? To take the boundary of a simplex
	$[v_0,\ldots,v_n]$, we remove each vertex one-by-one, and take
	the alternating sum. Therefore, $\partial([v]) = []$. Extending
	it linearly to complexes yields
	$\partial(\sum n_ip_i) = \sum n_i \cdot 1$ --- so $\eps$ really is
	just the boundary operator, generalized to the case
	$\wt C_0(X) \taking\partial \wt C_{-1}(X)$.\footnote{What about
		$n \leq -2$? An $n$-simplex comes from a list of vertices of
		length $(n+1)$, so a $(-2)$-simplex would require a list of
		vertices length $(-1)$ --- but there aren't any such lists. So
		while there is one $(-1)$-simplex, there are zero
		$(-2)$-simplices (ditto for $n < -2$). The free abelian
		group on zero elements is the trivial group, so
		$\wt C_{-2} \cong \mathbf{0}$. In particular,
		$\partial([]) = 0$.}
\end{example}

\begin{ques}
	What's the homology of the above chain at $\ZZ$?
	(Hint: you need $X$ nonempty.)
\end{ques}
\begin{definition}
	\label{def:augment}
	The homology groups of the augmented chain complex are called the
	\vocab{reduced homology groups} $\wt H_n(X)$ of the space $X$.

	Obviously $\wt H_n(X) \cong H_n(X)$ for $n > 0$.
	But when $n=0$, the map $H_0(X) \to \ZZ$ by $\eps$ has kernel $\wt H_0(X)$,
	thus $H_0(X) \cong \wt H_0(X) \oplus \ZZ$.
\end{definition}
This is usually just an added convenience.
For example, it means that if $X$ is contractible,
then all its reduced homology groups vanish,
and thus we won't have to keep fussing with the special $n=0$ case.
\begin{ques}
	Given the claim earlier about $H_n(S^m)$, what should $\wt H_n(S^m)$ be?
\end{ques}

\begin{example}
	[Relative chain groups]
	Suppose $X$ is a topological space, and $A \subseteq X$ a subspace.
	We can ``mod out'' by $A$ by defining
	\[ C_n(X,A) \defeq C_n(X) / C_n(A) \]
	for every $n$. Thus chains contained entirely in $A$ are trivial.

	Then, the usual $\partial$ on $C_n(X)$ generates a new chain complex
	\[ \dots \taking\partial C_{n+1}(X,A) \taking\partial C_n(X,A)
	\taking\partial C_{n-1}(X,A) \taking\partial \dots. \]

	This is well-defined since $\partial$ takes $C_n(A)$ into $C_{n-1}(A)$.
\end{example}
\begin{definition}
	The homology groups of the relative chain complex are the
	\vocab{relative homology groups} and denoted $H_n(X,A)$.
\end{definition}

One na\"{\i}ve guess is that this might equal $H_n(X) / H_n(A)$.
This is not true and in general doesn't even make sense;
if we take $X$ to be $\RR^2$ and $A = S^1$ a circle inside it,
we have $H_1(X) = H_1(\RR^2) = 0$ and $H_1(S^1) = \ZZ$.

Another guess is that $H_n(X,A)$ might just be $\wt H_n(X/A)$.
This will turn out to be true for most reasonable spaces $X$ and $A$,
and we will discuss this when we reach the excision theorem in \Cref{ch:relative_hom}.

\begin{example}
	[Mayer-Vietoris sequence]
	Suppose a space $X$ is covered by two open sets $U$ and $V$.
	We can define $C_n(U+V)$ as follows: it consists of chains such that
  the image of each simplex is either entirely contained in $U$,
	or entirely contained in $V$.

	Of course, $\partial$ then defines another chain complex
	\[ \dots \taking\partial C_{n+1}(U+V) \taking\partial C_n(U+V)
	\taking\partial C_{n-1}(U+V) \taking\partial \dots. \]
\end{example}
So once again, we can define homology groups for this complex;
we denote them by $H_n(U+V)$.
Miraculously, it will turn out that $H_n(U+V) \cong H_n(X)$.

\section\problemhead

\begin{problem}
	For $n \ge 1$ show that the composition
	\[ S^{n-1} \injto D^{n} \taking{F} S^{n-1} \]
	cannot be the identity map on $S^{n-1}$ for any continuous $F$.
	\begin{hint}
		Take the $n-1$st homology groups.
	\end{hint}
	\begin{sol}
		Applying the functor $H_{n-1}$ we get
		that the composition $\ZZ \to 0 \to \ZZ$ is the identity
		which is clearly not possible.
	\end{sol}
\end{problem}
\begin{problem}
	[Brouwer fixed point theorem]
	Use the previous problem to prove that any
	continuous function $f \colon D^n \to D^n$ has a fixed point.
	\begin{hint}
		Build $F$ as follows:
		draw the ray from $x$ through $f(x)$
		and intersect it with the boundary $S^{n-1}$.
	\end{hint}
\end{problem}
